using DG.Tweening;
using GooglePlayGames;
using System;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MenuController : MonoBehaviour
{
	private int a;

	public GameObject Logo;

	public GameObject Cloud;

	public GameObject StartGame;

	public GameObject TaptoPlay;

	public GameObject btnSound;

	public GameObject btnMusic;

	public GameObject btnRank;

	public GameObject[] sound_music;

	private GameObject AudioC;

	private const string LEADERBOARD_ID_Score = "CgkI9N_glMsVEAIQBg";

	private const string LEADERBOARD_ID_Gold = "CgkI9N_glMsVEAIQBw";

	private static bool IsInitialized;

	private void OnEnable()
	{
		AudioC = GameObject.FindGameObjectWithTag("Audio");
	}

	private void Start()
	{
		Social.localUser.Authenticate((Action<bool>)delegate
		{
		});
		if (GameManager.key_sound == 1)
		{
			sound_music[0].SetActive(value: true);
			sound_music[1].SetActive(value: false);
		}
		else
		{
			sound_music[0].SetActive(value: false);
			sound_music[1].SetActive(value: true);
		}
		if (GameManager.key_music == 1)
		{
			sound_music[2].SetActive(value: true);
			sound_music[3].SetActive(value: false);
			AudioC.GetComponent<AudioController>().MusicBackground.mute = false;
		}
		else
		{
			sound_music[2].SetActive(value: false);
			sound_music[3].SetActive(value: true);
			AudioC.GetComponent<AudioController>().MusicBackground.mute = true;
		}
		TaptoPlay.transform.DOScale(1.3f, 1f).SetEase(Ease.Linear).SetLoops(-1, LoopType.Yoyo);
		Logo.transform.DOScale(1.2f, 2f);
		Logo.transform.DOMove(new Vector3(2.6f, 1.9f, 0f), 1.5f).SetEase(Ease.OutBounce);
		Invoke("MoveCloud", 1.5f);
		if (GameManager.Tutorial == 0)
		{
			GameManager.levelUpgrade[4] = 5;
		}
		if (GameManager.Tutorial == 1)
		{
			GameManager.levelUpgrade[6] = -1;
		}
	}

	private void OnclickStart()
	{
		AudioController.Instance.SoundButtonAllGame();
		Invoke("ReadyStartGame", 0.2f);
	}

	private bool ShouldUniRateOpenRatePage()
	{
		return true;
	}

	private void MoveCloud()
	{
		AudioController.Instance.SoundKatanaStartGame();
		Cloud.transform.DOMoveX(1.95f, 0.25f).SetEase(Ease.InOutCirc);
		Invoke("ChangecolorLogo", 1f);
	}

	private void ChangecolorLogo()
	{
		StartGame.GetComponent<Collider>().enabled = true;
	}

	private void ReadyStartGame()
	{
		SceneManager.LoadScene("SelectMap");
	}

	private void OnclickSetting()
	{
		if (a % 2 == 0)
		{
			btnMusic.transform.DOLocalMoveY(-0.9f, 0.25f).SetEase(Ease.Linear);
			btnSound.transform.DOLocalMoveY(-1.8f, 0.25f).SetEase(Ease.Linear);
			btnRank.transform.DOLocalMoveY(-2.7f, 0.25f).SetEase(Ease.Linear);
		}
		else
		{
			btnMusic.transform.DOLocalMoveY(0f, 0.25f).SetEase(Ease.Linear);
			btnSound.transform.DOLocalMoveY(0f, 0.25f).SetEase(Ease.Linear);
			btnRank.transform.DOLocalMoveY(0f, 0.25f).SetEase(Ease.Linear);
		}
		a++;
	}

	private void OnclickSoundOn()
	{
		AudioController.Instance.SoundButtonAllGame();
		sound_music[0].SetActive(value: false);
		sound_music[1].SetActive(value: true);
		GameManager.key_sound = 0;
	}

	private void OnclickSoundOff()
	{
		AudioController.Instance.SoundButtonAllGame();
		sound_music[0].SetActive(value: true);
		sound_music[1].SetActive(value: false);
		GameManager.key_sound = 1;
	}

	private void OnclickMusicOn()
	{
		AudioController.Instance.SoundButtonAllGame();
		sound_music[2].SetActive(value: false);
		sound_music[3].SetActive(value: true);
		GameManager.key_music = 0;
		AudioC.GetComponent<AudioController>().MusicBackground.mute = true;
	}

	private void OnclickMusicOff()
	{
		AudioController.Instance.SoundButtonAllGame();
		sound_music[2].SetActive(value: true);
		sound_music[3].SetActive(value: false);
		GameManager.key_music = 1;
		AudioC.GetComponent<AudioController>().MusicBackground.mute = false;
	}

	private void OnclickRank()
	{
		AudioController.Instance.SoundButtonAllGame();
		((PlayGamesPlatform)Social.Active).ShowLeaderboardUI("CgkI-erF35AMEAIQAQ");
	}

	private void OnclickRate()
	{
		AudioController.Instance.SoundButtonAllGame();
		UniRate.Instance.RateIfNetworkAvailable();
		GameManager.rate = 1;
	}

	private void OnclickFacebook()
	{
		float timeSinceLevelLoad = Time.timeSinceLevelLoad;
		Application.OpenURL("fb://page/1838171629845010");
		if (Time.timeSinceLevelLoad - timeSinceLevelLoad <= 1f)
		{
			Application.OpenURL("https://www.facebook.com/StickmanGhost/");
		}
	}
}
